#define _CRT_SECURE_NO_WARNINGS 1
#include "headfile.h"
void STInit(ST* pst) {
	assert(pst);
	//STTypeDate* newspace = (STTypeDate*)malloc(sizeof(STTypeDate) * 4);
	//if (newspace == NULL)
	//{
	//	perror("malloc");
	//}
	//pst->a = newspace;
	pst->a = NULL;
	pst->top = -1;
	pst->capacity = 0;
}
void STPush(ST* pst, STTypeDate x) {
	assert(pst);
	if (pst->top + 1 == pst->capacity)
	{
		int newcapacity = pst->capacity == NULL ? 4 : pst->capacity * 2;
		STTypeDate* tmp = (STTypeDate*)realloc(pst->a, sizeof(STTypeDate) * newcapacity);
		if (tmp == NULL)
		{
			perror("realloc:");
			return;
		}
		pst->a = tmp;
		pst->capacity = newcapacity;
	}
	pst->top++;
	pst->a[pst->top] = x;
}
void STPop(ST* pst) {
	assert(pst);
	assert(pst->top >= 0);
	pst->top--;
}
STTypeDate STTop(ST* pst) {
	assert(pst);
	assert(pst->top >= 0);
	return pst->a[pst->top];
}
int STSize(ST* pst) {
	assert(pst);
	return pst->top + 1;
}
int STEmpty(ST* pst) {
	assert(pst);
	if (pst->top == -1)
		return -1;
	else
		return 0;
}
void STDistory(ST* pst) {
	assert(pst);
	free(pst->a);
	pst->a = NULL;
	pst->top = -1;
	pst->capacity = 0;
}
